package test;

import cn.xdd.dbutil.tesy;
import cn.xdd.entity.Book;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.log4j.Logger;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import static java.lang.Thread.sleep;
import static test.thread.Count;

/**
 * @author user_xdd
 * @Date 2022-04-06 13:02
 * @description
 * @return
 */
public class threadRun implements Runnable {
        private static  final Logger LOGGER = Logger.getLogger(threadRun.class);
    @Override
    public void run() {
        Count++;
        Connection conn = null;
        try {
            conn = tesy.getDataSource().getConnection();


        } catch (SQLException e) {
            e.printStackTrace();
        }
    
       
        //创建SQL执行工具
        QueryRunner queryRunner = new QueryRunner();
        String sql = "SELECT\n" +
                "\tbook.*\n" +
                "FROM\n" +
                "\tbook";
        List<Book> query = null;
        try {
            query = queryRunner.query(conn, sql, new BeanListHandler<>(Book.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        LOGGER.debug("    queryRunner.toString();:"+queryRunner.toString());
        LOGGER.debug("    Count:"+Count);
//        LOGGER.debug("    query:"+query);
    }
}
